<?php
if (empty($input['lang'])) {
    if (isset($input['maxchar']) || isset($input['prefix']) || isset($input['suffix'])) {?>
<div class="input-group input-group-alt <?php echo $input['class'] ?? '';?>">
    <?php
    }
    if (isset($input['maxchar'])) {?>
    <span id="<?php echo ($input['id'] ?? $input['name']);?>_counter" class="input-group-prepend">
        <span class="input-group-text"><?php echo $input['maxchar'];?></span>
    </span>
    <?php
    }
    if (isset($input['prefix'])) {?>
    <div class="input-group-prepend"><span class="input-group-text"><?php echo $input['prefix'];?></span></div>
    <?php
    }
    ?>
    <input type="text" id="<?php echo ($input['id'] ?? $input['name']);
    ?>" name="<?php echo $input['name'];
    ?>" class="form-control <?php echo $input['class'] ?? '';
    ?>" value="<?php echo $this->value[$input['name']] ?? '';?>" <?php
    if (isset($input['size'])) {?> size="<?php echo $input['size'];?>"<?php }
    if (isset($input['maxchar'])) {?> maxlength="<?php echo $input['maxchar'];?>"<?php }
    if (!empty($input['readonly'])) {?> readonly="readonly"<?php }
    if (!empty($input['disabled'])) {?> disabled="disabled"<?php }
    if (empty($input['autocomplete'])) {?> autocomplete="off"<?php }
    if (!empty($input['required'])) {?> required<?php }
    if (isset($input['placeholder'])) {?> placeholder="<?php echo $input['placeholder'];?>"<?php }?> />
    <?php
    if (isset($input['suffix'])) {?>
    <div class="input-group-append"><span class="input-group-text"><?php echo $input['suffix'];?></span></div>
    <?php
    }
    if (isset($input['maxchar']) || isset($input['prefix']) || isset($input['suffix'])) {?>
    </div>
    <?php
    }
} else {
    if ($langCount > 1) {?>
<div class="form-group">
    <?php
    }

    foreach($this->languages as $language) {
        if ($langCount > 1) {?>
    <div class="row lang lang-<?php echo $language['id'];
    ?>" <?php if ((int) $language['id'] !== APP_LANG_ID) {?>style="display:none"<?php }?>>
        <div class="col-lg-9"><?php
        }
        if (isset($input['maxchar']) || isset($input['prefix']) || isset($input['suffix'])) {?>
            <div class="input-group input-group-alt <?php echo $input['class'] ?? '';?>">
        <?php
        }
        if (isset($input['maxchar'])) {?>
            <span id="<?php echo ($input['id'] ?? $input['name']).'_'.$language['id'];?>_counter" class="input-group-prepend">
                <span class="input-group-text"><?php echo $input['maxchar'];?></span>
            </span>
        <?php
        }
        if (isset($input['prefix'])) {?>
            <div class="input-group-prepend"><span class="input-group-text"><?php echo $input['prefix'];?></span></div>
        <?php
        }
        ?>
            <input type="text" id="<?php echo ($input['id'] ?? $input['name']).'_'.$language['id'];
        ?>" name="<?php echo $input['name'].'_'.$language['id'];
        ?>" class="form-control <?php echo $input['class'] ?? '';
        ?>" value="<?php echo $this->value[$input['name']][$language['id']] ?? '';?>" <?php
        if (isset($input['size'])) {?> size="<?php echo $input['size'];?>"<?php }
        if (isset($input['maxchar'])) {?> maxlength="<?php echo $input['maxchar'];?>"<?php }
        if (!empty($input['readonly'])) {?> readonly="readonly"<?php }
        if (!empty($input['disabled'])) {?> disabled="disabled"<?php }
        if (empty($input['autocomplete'])) {?> autocomplete="off"<?php }
        if (!empty($input['required'])) {?> required<?php }
        if (isset($input['placeholder'])) {?> placeholder="<?php echo $input['placeholder'];?>"<?php }?> />
        <?php
        if (isset($input['suffix'])) {?>
            <div class="input-group-append"><span class="input-group-text"><?php echo $input['suffix'];?></span></div>
        <?php
        }
        if (isset($input['maxchar']) || isset($input['prefix']) || isset($input['suffix'])) {?>
            </div>
        <?php
        }
        if ($langCount > 1) {?>
        </div>
        <div class="col-lg-3">
            <div class="input-group-prepend dropdown">
                <button class="btn btn-secondary" type="button" data-toggle="dropdown"><?php
                echo $language['iso'];?> <span class="caret"></span></button>
                <div class="dropdown-arrow"></div>
                <div class="dropdown-menu"><?php
                foreach($this->languages as $language) {?>
                    <a class="dropdown-item" href="javascript:hideOtherLanguage(<?php echo $language['id'];?>);" tabindex="-1"><?php
                    echo $language['name'];?></a><?php
                }?>
                </div>
            </div>
        </div>
    </div>
<?php
        }
    }

    if ($langCount > 1) {?>
</div>
    <?php
    }
}